<template>
  <el-dialog
    title="详情"
    :close-on-click-modal="false"
    :visible.sync="visible">
    <el-form :model="dataForm" ref="dataForm" label-width="120px">
    <el-form-item label="合作方AppId">
      <el-input :value="dataForm.appId"></el-input>
    </el-form-item>
    <el-form-item label="调用时间">
      <el-input :value="dataForm.loginTime"></el-input>
    </el-form-item>
    <el-form-item label="调用状态">
      <el-input :value="dataForm.loginStateText"></el-input>
    </el-form-item>
    <el-form-item label="请求参数">
      <el-input :value="dataForm.requestData"></el-input>
    </el-form-item>
    <el-form-item label="响应结果">
      <el-input :value="dataForm.responseData"></el-input>
    </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
    </span>
  </el-dialog>
</template>

<script>
  export default {
    data () {
      return {
        visible: false,
        dataForm: {
          logId: 0,
          appId: '',
          loginTime: '',
          loginState: '',
          loginStateText: '',
          requestData: '',
          responseData: ''
        }
      }
    },
    methods: {
      init (id) {
        this.dataForm.logId = id || 0
        this.visible = true
        this.$nextTick(() => {
          this.$refs['dataForm'].resetFields()
          if (this.dataForm.logId) {
            this.$http({
              url: this.$http.adornUrl(`/partner/partnerloginlog/info/${this.dataForm.logId}`),
              method: 'get',
              params: this.$http.adornParams()
            }).then(({data}) => {
              if (data && data.code === 0) {
                this.dataForm.appId = data.partnerLoginLog.appId
                this.dataForm.loginTime = data.partnerLoginLog.loginTime
                this.dataForm.loginState = data.partnerLoginLog.loginState
                this.dataForm.loginStateText = data.partnerLoginLog.loginStateText
                this.dataForm.requestData = data.partnerLoginLog.requestData
                this.dataForm.responseData = data.partnerLoginLog.responseData
              }
            })
          }
        })
      }
    }
  }
</script>
